/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	hey 
 * 
 * <p>描   述  :   DangerBridgeServiceImpl.java for com.pengtu.gsj.service.impl.zhgl    </p>
 * 
 * <p>最后修改 : $: Sep 25, 2017-11:24:06 AM v 1.0.0	 hey   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.zhgl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.zhgl.DangerBridgeDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.zhgl.DangerBridge;
import com.pengtu.gsj.service.system.SystemManageService;
import com.pengtu.gsj.service.zhgl.DangerBridgeService;

/**
 * 
 * DangerBridgeServiceImpl
 * 
 * Sep 25, 2017 11:24:06 AM
 * 
 * @version 1.0.0
 * 
 */
@Service
@Transactional
public class DangerBridgeServiceImpl implements DangerBridgeService{
	
	@Autowired
	private DangerBridgeDao dangerBridgeDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	
	
	@Override
	public void saveDangerBridge(DangerBridge dangerBridge){
		dangerBridgeDao.save(dangerBridge);
	}
	
	@Override
	public Page<DangerBridge> findDangerBridge(Page<DangerBridge> page, final QueryFilter queryFilter){
		return dangerBridgeDao.findPage(page, queryFilter);
	}
	
	@Override
	public DangerBridge getDangerBridgeById(String id){
		return dangerBridgeDao.get(id);
	}
	
	@Override
	public void  delateDangerBridge(DangerBridge dangerBridge){
		if(dangerBridge.getAttachments() != null){
			for(Attachment attachment : dangerBridge.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		dangerBridgeDao.delete(dangerBridge);
	}
	
	@Override
	public boolean checkTecYear(String testYear, String id){
		return dangerBridgeDao.checkProperty("testYear", testYear, id);
	}
}
